﻿using Rhinestone.Shared;

namespace LinqRepositorySample.Data.NHibernate
{
    public class NHibernateTransaction : ITransaction
    {
        #region fields
        private readonly global::NHibernate.ITransaction _transaction;
        #endregion

        #region ctor
        /// <summary>
        /// Default Constructor.
        /// Creates a new instance of the <see cref="NHibernateTransaction"/> class.
        /// </summary>
        /// <param name="transaction">The internal NHibernate transaction to wrap.</param>
        public NHibernateTransaction(global::NHibernate.ITransaction transaction)
        {
            _transaction = transaction;
        }
        #endregion

        #region methods
        /// <summary>
        /// Disposes off the reosources used by the transaction.
        /// </summary>
        public void Dispose()
        {
            _transaction.Dispose();
        }

        /// <summary>
        /// Commits the transaction.
        /// </summary>
        public void Commit()
        {
            _transaction.Commit();
        }

        /// <summary>
        /// Rollsback the transaction.
        /// </summary>
        public void Rollback()
        {
            _transaction.Rollback();
        }
        #endregion
    }
}
